<?php

/**
  * SquirrelMail Yubikey Plugin
  * @copyright &copy; 2009 Richard Ferguson <yubikey@fergusnet.com>
  * @license http://opensource.org/licenses/gpl-license.php GNU Public License
  * @package plugins
  * @subpackage yubikey
  */

/* add hooks into squirrelmail */
function squirrelmail_plugin_init_yubikey() 
{
   global $squirrelmail_plugin_hooks;
   $squirrelmail_plugin_hooks['optpage_loadhook_personal']['yubikey'] = 'yubikey_options';
   $squirrelmail_plugin_hooks['login_form']['yubikey'] = 'yubikey_form';
   $squirrelmail_plugin_hooks['login_before']['yubikey'] = 'yubikey_login';
   $squirrelmail_plugin_hooks['login_verified']['yubikey'] = 'yubikey_verify';
}

/* return plugin information */
function yubikey_info()
{
   return array(
             'english_name' => 'Yubikey',
             'authors' => array(
                'Richard Ferguson' => array (
                   'email' => 'yubikey@fergusnet.com',
                ),
             ),                
             'version' => '0.7',
             'required_sm_version' => '1.4.0',
             'required_php_version' => '5.0',
             'required_php_modules' => array('curl'),
             'required_php_functions' => array('array_search', 'urlencode', 
                                               'base64_encode', 'base64_decode', 
                                               'hash_hmac', 'parse_url',
                                               'date_format', 'date_create'),
             'summary' => 'Provide Yubkey One-Time-Password authentication.',
             'details' => 'This plugin enables the integration of Yubikey One-Time-Password authentication.  This provides multi-factor authentication in form of something you know and something you have.', 
             'requires_configuration' => 1,
             'requires_source_patch' => 0,
             'external_project_uri' => 'http://code.google.com/p/yubico-squirrelmail-plugin/',
          );
}

/* return plugin version */
function yubikey_version()
{
   $info = yubikey_info();
   return $info['version'];
}

/* insert yubikey options into personal preferences page */
function yubikey_options() 
{
   include_once(SM_PATH . 'plugins/yubikey/functions.php');
   yubikey_options_do();
}

/* add yubikey input box */
function yubikey_form() 
{
   include_once(SM_PATH . 'plugins/yubikey/functions.php');
   yubikey_form_do();
}

/* process yubikey otp from login form */
function yubikey_login() 
{
   include_once(SM_PATH . 'plugins/yubikey/functions.php');
   yubikey_login_do();
}

/* verify yubikey otp */
function yubikey_verify() 
{
   include_once(SM_PATH . 'plugins/yubikey/functions.php');
   yubikey_verify_do();
}

// vim: ts=4: expandtab
